/*MyPhotoIndex Free Photo Organizer <www.myphotoindex.com>
  Copyright (C) <2006-2009>  <Asaf Yarkoni asaf@yarkoni.net>

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
using System;
using System.Collections.Generic;
using System.Text;
using MyPhotoIndex.Interfaces;

namespace MyPhotoIndex
{
    class ActiveProcess : IProcessProgress
    {
        internal event EventHandler<ProcessInfoAlertParameters> AlertEvent;

        #region IProcessProgress Members

        private ProgressStats m_stats = new ProgressStats(100);
        public ProgressStats Stats
        {
            get { return m_stats; }
        }

        private int m_rocessId;
        public int ProcessId
        {
            get
            {
                return m_rocessId;
            }
            set
            {
                m_rocessId = value;
            }
        }

        private int m_maximum;
        public int Maximum
        {
            get
            {
                return m_maximum;
            }
            set
            {
                if (m_maximum != value)
                {
                    m_stats = new ProgressStats(value);
                }
                m_maximum = value;
            }
        }

        private int m_value;
        public int Value
        {
            get
            {
                return m_value;
            }
            set
            {
                m_value = value;
                if (m_stats != null)
                {
                    m_stats.Update(value);
                }
            }
        }

        private String m_processDescription;
        public string ProcessDescription
        {
            get
            {
                return m_processDescription;
            }
            set
            {
                m_processDescription = value;
            }
        }

        private String m_processMessage;
        public string ProcessMessage
        {
            get
            {
                return m_processMessage;
            }
            set
            {
                m_processMessage = value;
            }
        }

        private bool m_running;
        public bool Running
        {
            get
            {
                return m_running;
            }
            set
            {
                m_running = value;
            }
        }

        private bool m_isInfinite;
        public bool IsInfinite
        {
            get
            {
                return m_isInfinite;
            }
            set
            {
                m_isInfinite = value;
            }
        }

        private DateTime m_lastAccessed;
        public DateTime LastAccessed
        {
            get { return m_lastAccessed; }
            set { m_lastAccessed = value; }
        }

        public void Alert(ProcessAlertType alertType, string message, string description, string url)
        {
            if (AlertEvent != null)
            {
                AlertEvent.Invoke(this, new ProcessInfoAlertParameters(alertType, message, description, url));
            }
        }

        #endregion
    }
}
